<?php
/* ----------------------------------------------------------
--               JacoCMS by Jaco Ruit                      --
-------------------------------------------------------------
--     JacoCMS is Open Source and is lincenced under       --
--             GNU General Public Licence v3               --
--          http://www.gnu.org/copyleft/gpl.html           --
-------------------------------------------------------------
--       Please don't remove any text from the footers.    --
-------------------------------------------------------------
-- Credits:   * Jaco Ruit          ~     Scripts,MySQL     --     
-----------------------------------------------------------*/

#important includes
include '../includes/config.php';
include '../includes/database.ext.class.php'; 

#create database connection
$database = new Database();
$database->connect('../includes/config.php');

#finish includes
include '../includes/core.ext.class.php';
include '../includes/settings.class.php';
include '../includes/user.class.php';

#vars, classes
$settings = new Settings();
$core = new Core();
$user = new User();


#checkvars
if((isset($_POST['uname'])) && (isset($_POST['pwd'])) && (isset($_POST['pwd2'])) && (isset($_POST['email'])))
{
	$uname = $core->filter($_POST['uname']);
	$pwd = $core->filter($_POST['pwd']);
	$pwd2 = $core->filter($_POST['pwd2']);
	$email = $core->filter($_POST['email']);
	
	if ($pwd !== $pwd2)
	{
		header("Location: register?e=1");
	}
	else
	{
	
		if($user->checkIfUnameExists($uname))
		{	
			header("Location: register?e=2");
		}
		else
		{
			$user->register($uname, $pwd, $email, '1');
			header("Location: login?msg=1");
		}
	}
}
else
{
	header("Location: register");
}

?>
